package Project;
//___________________________IMPORTACIONES______________________________________

import Validaciones.*;
import java.awt.*;
import java.sql.*;
import javax.swing.*;
import javax.swing.table.*;
//______________________________________________________________________________

public class IngresarConductor extends javax.swing.JPanel {
//_____________________________ATRIBUTOS________________________________________

    int Dialog;
    String sql;
//_____________________________CONSTRUCTOR______________________________________

    public IngresarConductor() {
        initComponents();
        String a = Container.lblPrivilegio.getText();

        if (a.equals("3")) {
            for (int i = 0; i < jPanel1.getComponents().length; i++) {
                jPanel1.getComponent(i).setEnabled(false);
            }
            btnVerTabla.setEnabled(true);
            btnModificar.setEnabled(false);
            btnEliminar.setEnabled(false);
        }
        lblIdEstadoCivil.setVisible(false);
        dlgCargandoDatos.setDefaultCloseOperation(0);
    }
//______________________________________________________________________________

    private void tamanoTabla() {

        int ancho = 800;
        int anchoColumna = 0;
        TableColumnModel modeloColumna = tablaConductor.getColumnModel();
        TableColumn columnaTabla;
        for (int i = 0; i < tablaConductor.getColumnCount(); i++) {
            columnaTabla = modeloColumna.getColumn(i);
            switch (i) {
                case 0:
                    anchoColumna = (25 * ancho) / 100;
                    break;
                case 1:
                    anchoColumna = (25 * ancho) / 100;
                    break;
                case 2:
                    anchoColumna = (25 * ancho) / 100;
                    break;
                case 3:
                    anchoColumna = (25 * ancho) / 100;
                    break;
                case 4:
                    anchoColumna = (25 * ancho) / 100;
                    break;
                case 5:
                    anchoColumna = (25 * ancho) / 100;
                    break;
                case 6:
                    anchoColumna = (25 * ancho) / 100;
                    break;
            }
            columnaTabla.setPreferredWidth(anchoColumna);
        }

    }
//______________________________________________________________________________

    private void ocultarColumnas() {
        int i;
        for (i = 1; i < 3; i++) {
            tablaConductor.getColumnModel().getColumn(i).setMaxWidth(0);
            tablaConductor.getColumnModel().getColumn(i).setMinWidth(0);
            tablaConductor.getColumnModel().getColumn(i).setPreferredWidth(0);
            tablaConductor.getColumnModel().getColumn(i).setResizable(false);
        }
    }
//______________________________________________________________________________

    private void llenarConductores(String Valor) {

        BaseDeDatos.conectarse();

        try {

            String consulta = "SELECT conductor.nombre_completo, conductor.nombre, conductor.apellido, conductor.cedula, conductor.direccion,"
                    + " conductor.edad, conductor.telefono, estado_civil.estado_civil AS conductor FROM conductor JOIN estado_civil"
                    + " ON (estado_civil.id = conductor.estado_civil_id)";

            int Valor_dos = cbxFiltro.getSelectedIndex();

            if (Valor_dos == 0) {
                sql = consulta + " WHERE conductor.nombre_completo ILIKE '" + Valor + "%' ORDER BY conductor.nombre_completo";
            } else if (Valor_dos == 1) {
                sql = consulta + " WHERE CAST(cedula AS CHAR(15)) LIKE '" + Valor + "%' ORDER BY conductor.nombre_completo";
            }

            DefaultTableModel modelo = new DefaultTableModel();
            tablaConductor.setModel(modelo);
            modelo.addColumn("NOMBRE");
            modelo.addColumn("NOMBRE");
            modelo.addColumn("APELLIDO");
            modelo.addColumn("CEDULA");
            modelo.addColumn("DIRECCION");
            modelo.addColumn("EDAD");
            modelo.addColumn("TELEFONO");
            modelo.addColumn("ESTADO CIVIL");

            Statement s = BaseDeDatos.con.createStatement();
            ResultSet rs = s.executeQuery(sql);

            while (rs.next()) {
                // Se crea un array que será una de las filas de la tabla. 
                Object[] fila = new Object[8]; // Hay 8 columnas en la tabla

                // Se rellena cada posición del array con una de las columnas de la tabla en base de datos.
                for (int i = 0; i < 8; i++) {
                    fila[i] = rs.getObject(i + 1); // El primer indice en rs es el 1, no el cero, por eso se suma 1.
                }
                // Se añade al modelo la fila completa.
                modelo.addRow(fila);
            }
            BaseDeDatos.desconectarse();
            tablaConductor.setModel(modelo);
            tamanoTabla();
            ocultarColumnas();
        } catch (SQLException ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
        }

    }
//______________________________________________________________________________

    private void ingresarConductor() {

        BaseDeDatos.conectarse();

        Dialog = JOptionPane.showConfirmDialog(null, "Esta seguro de ingresar este nuevo registro",
                "Advertencia", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);

        if (Dialog == JOptionPane.YES_NO_OPTION) {
            try {
                String a = txtNombre.getText();
                String b = txtApellido.getText();
                String c = txtIdConductor.getText();
                String d = txtDireccion.getText();
                String e = txtEdad.getText();
                String x = txtTelefono.getText();
                String f = lblIdEstadoCivil.getText();

                sql = "insert into conductor values ('" + a.toLowerCase() + " " + b.toLowerCase() + "','" + a.toLowerCase() + "','" + b.toLowerCase() + "'," + c + ",'" + d.toLowerCase() + "'," + e + "," + x + "," + f + ")";
                int resultado = BaseDeDatos.stmt.executeUpdate(sql);
                if (resultado == 1) {
                    JOptionPane.showMessageDialog(null, "El registro se agrego de manera exitosa", "Info", JOptionPane.INFORMATION_MESSAGE);

                    txtNombre.setText("");
                    txtApellido.setText("");
                    txtIdConductor.setText("");
                    txtDireccion.setText("");
                    txtEdad.setText("");
                    txtTelefono.setText("");
                    cbxEstadoCivil.setSelectedIndex(0);

                }
            } catch (SQLException | HeadlessException e) {
                JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
            }
        }
        BaseDeDatos.desconectarse();
        llenarConductores("");
    }
//______________________________________________________________________________

    private void eliminarConductor() {

        BaseDeDatos.conectarse();

        if (tablaConductor.getSelectedRows().length < 1) {
            JOptionPane.showMessageDialog(null, "Seleccione Una Fila", "Error", JOptionPane.ERROR_MESSAGE);
        } else if (JOptionPane.showConfirmDialog(null, "Esta seguro de que desea eliminar este registro",
                "Advertencia", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_NO_OPTION) {
            try {
                lblIdConductor.setText("" + tablaConductor.getValueAt(tablaConductor.getSelectedRow(), 3));
                String d = lblIdConductor.getText();
                sql = "delete  from conductor where cedula=" + d;
                int resultado = BaseDeDatos.stmt.executeUpdate(sql);
                if (resultado == 1) {
                    JOptionPane.showMessageDialog(null, "El registro a sido eliminado", "Info", JOptionPane.INFORMATION_MESSAGE);
                }
                txtBuscar.setText("");
            } catch (SQLException | HeadlessException e) {
                JOptionPane.showMessageDialog(null, "El registro no se pudo borrar", "Error", JOptionPane.ERROR_MESSAGE);
            }
        }
        BaseDeDatos.desconectarse();
        llenarConductores("");
    }
//______________________________________________________________________________

    private void modificarConductor() {

        int valor = EstadoCivil.getSelectedIndex();
        String id = lblIdConductor.getText();
        String a = txtNuevoNombre.getText();
        String b = txtNuevoApellido.getText();
        String c = txtNuevaId.getText();
        String d = txtNuevaDireccion.getText();

        BaseDeDatos.conectarse();

        if (a.equals("") || b.equals("") || c.equals("") || d.equals("") || txtNuevaEdad.getText().equals("") || txtNuevoTelefono.getText().equals("") || valor == 0) {
            JOptionPane.showMessageDialog(null, "Hay Campos Vacios", "Error", JOptionPane.ERROR_MESSAGE);
        } else if (JOptionPane.showConfirmDialog(null, "Esta seguro de que desea modificar este registro",
                "Advertencia", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.YES_NO_OPTION) {
            try {

                String e = txtNuevaEdad.getText();
                String h = txtNuevoTelefono.getText();
                String f = EstadoId.getText();

                if (valor == 1) {
                    EstadoCivilId.setText("1");
                } else if (valor == 2) {
                    EstadoCivilId.setText("2");
                } else if (valor == 3) {
                    EstadoCivilId.setText("3");
                } else if (valor == 4) {
                    EstadoCivilId.setText("4");
                } else if (valor == 5) {
                    EstadoCivilId.setText("5");
                } else if (valor == 6) {
                    EstadoCivilId.setText("6");
                }

                sql = "update conductor set nombre_completo='" + a.toLowerCase() + " " + b.toLowerCase() + "', nombre='" + a.toLowerCase() + "', apellido='" + b.toLowerCase() + "', cedula=" + c + ", direccion='" + d.toLowerCase() + "', edad=" + e + ", telefono=" + h + ", estado_civil_id=" + f + " where cedula=" + id;
                int resultado = BaseDeDatos.stmt.executeUpdate(sql);
                if (resultado == 1) {
                    JOptionPane.showMessageDialog(null, "El registro a sido modificado exitosamente", "Info", JOptionPane.INFORMATION_MESSAGE);
                    txtNuevoNombre.setText("");
                    txtNuevoApellido.setText("");
                    txtNuevaId.setText("");
                    txtNuevaDireccion.setText("");
                    txtNuevaEdad.setText("");
                    txtNuevoTelefono.setText("");
                    txtBuscar.setText("");
                    dlgModificar.setVisible(false);
                }

            } catch (SQLException | HeadlessException e) {
                JOptionPane.showMessageDialog(null, e.getMessage() + "El registro no se pudo  modificar", "Error", JOptionPane.ERROR_MESSAGE);
            }
        }
        BaseDeDatos.desconectarse();
        llenarConductores("");
    }
//______________________________________________________________________________  

    public class hiloConductores implements Runnable {

        @Override
        @SuppressWarnings("SleepWhileInLoop")
        public void run() {
            for (int i = 0; i <= 100; i++) {
                try {
                    pbCargarDatos.setValue(i);
                    pbCargarDatos.repaint();
                    Thread.sleep(10);
                    if (pbCargarDatos.getValue() == 1) {
                        llenarConductores("");
                    } else if (pbCargarDatos.getValue() == 100) {
                        pbCargarDatos.setValue(0);
                        dlgCargandoDatos.dispose();
                        dlgTablaConductor.setLocationRelativeTo(null);
                        dlgTablaConductor.setVisible(true);
                    }
                } catch (InterruptedException e) {
                    JOptionPane.showMessageDialog(null, e.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
                }
            }
        }
    }
//______________________________________________________________________________

    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        dlgTablaConductor = new javax.swing.JDialog();
        jPanel2 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tablaConductor = new javax.swing.JTable(){
            public boolean isCellEditable(int rowIndex, int colIndex) {
                return false; //Disallow the editing of any cell
            }
        };
        btnEliminar = new javax.swing.JButton();
        btnModificar = new javax.swing.JButton();
        lblIdConductor = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        txtBuscar = new javax.swing.JTextField();
        cbxFiltro = new javax.swing.JComboBox();
        dlgModificar = new javax.swing.JDialog();
        jPanel3 = new javax.swing.JPanel();
        jLabel9 = new javax.swing.JLabel();
        txtNuevoNombre = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        txtNuevoApellido = new javax.swing.JTextField();
        jLabel11 = new javax.swing.JLabel();
        txtNuevaId = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        txtNuevaDireccion = new javax.swing.JTextField();
        jLabel13 = new javax.swing.JLabel();
        txtNuevaEdad = new javax.swing.JTextField();
        btnAceptar = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        EstadoCivil = new javax.swing.JComboBox();
        EstadoCivilId = new javax.swing.JLabel();
        EstadoId = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        txtNuevoTelefono = new javax.swing.JTextField();
        dlgCargandoDatos = new javax.swing.JDialog();
        pbCargarDatos = new javax.swing.JProgressBar();
        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        txtNombre = new javax.swing.JTextField();
        txtApellido = new javax.swing.JTextField();
        txtIdConductor = new javax.swing.JTextField();
        txtDireccion = new javax.swing.JTextField();
        txtEdad = new javax.swing.JTextField();
        btnIngresar = new javax.swing.JButton();
        btnVerTabla = new javax.swing.JButton();
        jLabel14 = new javax.swing.JLabel();
        cbxEstadoCivil = new javax.swing.JComboBox();
        lblIdEstadoCivil = new javax.swing.JLabel();
        jLabel15 = new javax.swing.JLabel();
        txtTelefono = new javax.swing.JTextField();

        dlgTablaConductor.setTitle("Conductores");
        dlgTablaConductor.setMinimumSize(new java.awt.Dimension(795, 561));
        dlgTablaConductor.setModal(true);
        dlgTablaConductor.setResizable(false);

        jPanel2.setMaximumSize(new java.awt.Dimension(775, 539));
        jPanel2.setMinimumSize(new java.awt.Dimension(775, 539));

        tablaConductor.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        tablaConductor.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {

            }
        ));
        tablaConductor.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        tablaConductor.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        tablaConductor.setEditingRow(0);
        tablaConductor.setRowHeight(24);
        tablaConductor.getTableHeader().setResizingAllowed(false);
        tablaConductor.getTableHeader().setReorderingAllowed(false);
        jScrollPane1.setViewportView(tablaConductor);

        btnEliminar.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        btnEliminar.setText("Eliminar");
        btnEliminar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        btnEliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnEliminarActionPerformed(evt);
            }
        });

        btnModificar.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        btnModificar.setText("Modificar");
        btnModificar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        btnModificar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnModificarActionPerformed(evt);
            }
        });

        lblIdConductor.setBorder(new javax.swing.border.MatteBorder(null));

        jLabel3.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel3.setText("Filtrar por:");

        txtBuscar.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        txtBuscar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        txtBuscar.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                txtBuscarKeyReleased(evt);
            }
        });

        cbxFiltro.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        cbxFiltro.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Nombre", "Cedula" }));
        cbxFiltro.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        cbxFiltro.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbxFiltroItemStateChanged(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 755, Short.MAX_VALUE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(btnEliminar, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnModificar, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblIdConductor, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 65, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(10, 10, 10)
                        .addComponent(cbxFiltro, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(10, 10, 10)
                        .addComponent(txtBuscar)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtBuscar, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbxFiltro, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 434, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lblIdConductor, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(btnEliminar, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(btnModificar, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(23, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout dlgTablaConductorLayout = new javax.swing.GroupLayout(dlgTablaConductor.getContentPane());
        dlgTablaConductor.getContentPane().setLayout(dlgTablaConductorLayout);
        dlgTablaConductorLayout.setHorizontalGroup(
            dlgTablaConductorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dlgTablaConductorLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        dlgTablaConductorLayout.setVerticalGroup(
            dlgTablaConductorLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dlgTablaConductorLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        dlgModificar.setTitle("Modificar Conductor");
        dlgModificar.setMinimumSize(new java.awt.Dimension(349, 385));
        dlgModificar.setModal(true);
        dlgModificar.setResizable(false);

        jPanel3.setMaximumSize(new java.awt.Dimension(297, 300));
        jPanel3.setMinimumSize(new java.awt.Dimension(297, 300));

        jLabel9.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel9.setText("Nombre:");

        txtNuevoNombre.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        txtNuevoNombre.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        txtNuevoNombre.setMargin(new java.awt.Insets(0, 5, 0, 5));

        jLabel10.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel10.setText("Apellido:");

        txtNuevoApellido.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        txtNuevoApellido.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        txtNuevoApellido.setMargin(new java.awt.Insets(0, 5, 0, 5));

        jLabel11.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel11.setText("Cedula:");

        txtNuevaId.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        txtNuevaId.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        txtNuevaId.setMargin(new java.awt.Insets(0, 5, 0, 5));

        jLabel12.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel12.setText("Dirección:");

        txtNuevaDireccion.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        txtNuevaDireccion.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        txtNuevaDireccion.setMargin(new java.awt.Insets(0, 5, 0, 5));

        jLabel13.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel13.setText("Edad:");

        txtNuevaEdad.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        txtNuevaEdad.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        txtNuevaEdad.setMargin(new java.awt.Insets(0, 5, 0, 5));

        btnAceptar.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        btnAceptar.setText("Aceptar");
        btnAceptar.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        btnAceptar.setMaximumSize(new java.awt.Dimension(100, 24));
        btnAceptar.setMinimumSize(new java.awt.Dimension(100, 24));
        btnAceptar.setPreferredSize(new java.awt.Dimension(100, 24));
        btnAceptar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnAceptarActionPerformed(evt);
            }
        });

        jLabel2.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel2.setText("Estado Civil:");

        EstadoCivil.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        EstadoCivil.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "-------------------------------", "Soltero/a", "Casado/a", "Divorciado/a", "Viudo/a", "Unión libre", "Separado/a" }));
        EstadoCivil.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        EstadoCivil.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                EstadoCivilItemStateChanged(evt);
            }
        });

        EstadoCivilId.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        EstadoId.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jLabel16.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel16.setText("Telefono:");

        txtNuevoTelefono.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        txtNuevoTelefono.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        txtNuevoTelefono.setMargin(new java.awt.Insets(0, 5, 0, 5));

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE)
                                .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(txtNuevoApellido)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtNuevaId, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(txtNuevoNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(0, 0, Short.MAX_VALUE))))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(btnAceptar, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(EstadoCivilId, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(EstadoId, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel12, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE)
                            .addComponent(jLabel13, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel16, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGap(4, 4, 4)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(txtNuevaDireccion)
                                    .addGroup(jPanel3Layout.createSequentialGroup()
                                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(txtNuevoTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
                                            .addComponent(txtNuevaEdad, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE))
                                        .addGap(0, 0, Short.MAX_VALUE))))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(EstadoCivil, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(0, 0, Short.MAX_VALUE)))))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addGap(15, 15, 15)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtNuevoNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtNuevoApellido, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtNuevaId, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtNuevaDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtNuevaEdad, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel16, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtNuevoTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(EstadoCivil, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(20, 20, 20)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(btnAceptar, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(EstadoCivilId, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(EstadoId, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout dlgModificarLayout = new javax.swing.GroupLayout(dlgModificar.getContentPane());
        dlgModificar.getContentPane().setLayout(dlgModificarLayout);
        dlgModificarLayout.setHorizontalGroup(
            dlgModificarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dlgModificarLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(14, Short.MAX_VALUE))
        );
        dlgModificarLayout.setVerticalGroup(
            dlgModificarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dlgModificarLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(40, Short.MAX_VALUE))
        );

        dlgCargandoDatos.setTitle("Gargando Datos...");
        dlgCargandoDatos.setMinimumSize(new java.awt.Dimension(267, 72));
        dlgCargandoDatos.setModal(true);
        dlgCargandoDatos.setResizable(false);

        pbCargarDatos.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        javax.swing.GroupLayout dlgCargandoDatosLayout = new javax.swing.GroupLayout(dlgCargandoDatos.getContentPane());
        dlgCargandoDatos.getContentPane().setLayout(dlgCargandoDatosLayout);
        dlgCargandoDatosLayout.setHorizontalGroup(
            dlgCargandoDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dlgCargandoDatosLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pbCargarDatos, javax.swing.GroupLayout.DEFAULT_SIZE, 247, Short.MAX_VALUE)
                .addContainerGap())
        );
        dlgCargandoDatosLayout.setVerticalGroup(
            dlgCargandoDatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dlgCargandoDatosLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(pbCargarDatos, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(37, Short.MAX_VALUE))
        );

        setAlignmentX(0.0F);
        setAlignmentY(0.0F);

        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/logo.png"))); // NOI18N

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)), "Ingresar Nuevo Conductor", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 14), new java.awt.Color(0, 0, 0))); // NOI18N
        jPanel1.setMaximumSize(new java.awt.Dimension(953, 503));
        jPanel1.setMinimumSize(new java.awt.Dimension(953, 503));
        jPanel1.setPreferredSize(new java.awt.Dimension(953, 503));

        jLabel4.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel4.setText("Nombre:");

        jLabel5.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel5.setText("Apellido:");

        jLabel6.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel6.setText("Cedula:");

        jLabel7.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel7.setText("Dirección:");

        jLabel8.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel8.setText("Edad:");

        txtNombre.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        txtNombre.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        txtNombre.setMargin(new java.awt.Insets(0, 5, 0, 5));

        txtApellido.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        txtApellido.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        txtApellido.setMargin(new java.awt.Insets(0, 5, 0, 5));

        txtIdConductor.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        txtIdConductor.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        txtIdConductor.setMargin(new java.awt.Insets(0, 5, 0, 5));

        txtDireccion.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        txtDireccion.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        txtDireccion.setMargin(new java.awt.Insets(0, 5, 0, 5));

        txtEdad.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        txtEdad.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        txtEdad.setMargin(new java.awt.Insets(0, 5, 0, 5));

        btnIngresar.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        btnIngresar.setText("Ingresar");
        btnIngresar.setBorder(null);
        btnIngresar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnIngresarActionPerformed(evt);
            }
        });

        btnVerTabla.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        btnVerTabla.setText("Ver Tabla");
        btnVerTabla.setBorder(null);
        btnVerTabla.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnVerTablaActionPerformed(evt);
            }
        });

        jLabel14.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel14.setText("Estado Civil:");

        cbxEstadoCivil.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        cbxEstadoCivil.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "[Seleccion Estado Civil]", "Soltero/a", "Casado/a", "Divorciado/a", "Viudo/a", "Unión libre", "Separado/a" }));
        cbxEstadoCivil.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        cbxEstadoCivil.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                cbxEstadoCivilItemStateChanged(evt);
            }
        });

        lblIdEstadoCivil.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

        jLabel15.setFont(new java.awt.Font("Arial", 1, 12)); // NOI18N
        jLabel15.setText("Telefono:");

        txtTelefono.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        txtTelefono.setMargin(new java.awt.Insets(0, 5, 0, 5));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(318, 318, 318)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(btnIngresar, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnVerTabla, javax.swing.GroupLayout.PREFERRED_SIZE, 100, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(lblIdEstadoCivil, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jLabel15, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel14, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE)
                            .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel4, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(10, 10, 10)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(txtIdConductor, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtEdad, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtApellido)
                            .addComponent(txtNombre, javax.swing.GroupLayout.DEFAULT_SIZE, 216, Short.MAX_VALUE)
                            .addComponent(txtDireccion)
                            .addComponent(cbxEstadoCivil, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(txtTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addGap(15, 15, 15)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtApellido, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(txtIdConductor, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtEdad, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel15, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(txtTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(15, 15, 15)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel14, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cbxEstadoCivil, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(20, 20, 20)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(btnIngresar, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnVerTabla, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(lblIdEstadoCivil, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(156, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 960, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 960, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGap(5, 5, 5))
        );
    }// </editor-fold>//GEN-END:initComponents
//______________________________________________________________________________

    private void btnVerTablaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnVerTablaActionPerformed

        new Thread(new hiloConductores()).start();
        dlgCargandoDatos.setLocationRelativeTo(null);
        dlgCargandoDatos.setVisible(true);
        lblIdConductor.setVisible(false);
        tablaConductor.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        tablaConductor.setAutoCreateRowSorter(true);

    }//GEN-LAST:event_btnVerTablaActionPerformed
//______________________________________________________________________________

    @SuppressWarnings("UnusedAssignment")
    private void btnIngresarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnIngresarActionPerformed

        String nombre = txtNombre.getText();
        String apellido = txtApellido.getText();
        String cedula = txtIdConductor.getText();
        String direccion = txtDireccion.getText();
        String edad = txtEdad.getText();
        String telefono = txtTelefono.getText();
        int f = cbxEstadoCivil.getSelectedIndex();
        boolean valida = true;

        while (valida) {

            if (ValidacionesPropietario.ValidacionesNomApe(nombre, txtNombre) || ValidacionesPropietario.ValidacionesNomApe(apellido, txtApellido) || ValidacionesPropietario.validaCedula(cedula, txtIdConductor)
                    || ValidacionesOpciones.validaDirecciones(direccion, txtDireccion) || ValidacionesPropietario.validaEdad(edad, txtEdad) || ValidacionesPropietario.validaTelefono(telefono, txtTelefono) || ValidacionesPropietario.validaEstado(f, cbxEstadoCivil)) {
                valida = false;
                JOptionPane.showMessageDialog(jPanel1, "Por favor verifique los datos ingresados", "Error", JOptionPane.ERROR_MESSAGE);

            } else {
                ingresarConductor();
                txtNombre.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
                txtApellido.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
                txtIdConductor.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
                txtDireccion.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
                txtEdad.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
                txtTelefono.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
                cbxEstadoCivil.setSelectedIndex(0);
                cbxEstadoCivil.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
                txtNombre.requestFocus();
            }
            valida = false;
        }

    }//GEN-LAST:event_btnIngresarActionPerformed
//______________________________________________________________________________

    private void btnEliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnEliminarActionPerformed

        eliminarConductor();

    }//GEN-LAST:event_btnEliminarActionPerformed
//______________________________________________________________________________

    private void btnModificarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnModificarActionPerformed

        if (tablaConductor.getSelectedRows().length < 1) {

            JOptionPane.showMessageDialog(null, "Seleccione Una Fila", "Error", JOptionPane.ERROR_MESSAGE);

        } else {

            EstadoCivilId.setVisible(false);
            EstadoId.setVisible(false);
            dlgModificar.setLocationRelativeTo(null);
            String valor = "" + tablaConductor.getValueAt(tablaConductor.getSelectedRow(), 7);
            EstadoCivilId.setText("" + valor);
            String h = EstadoCivilId.getText();

            txtNuevoNombre.setText("" + tablaConductor.getValueAt(tablaConductor.getSelectedRow(), 1));
            txtNuevoApellido.setText("" + tablaConductor.getValueAt(tablaConductor.getSelectedRow(), 2));
            txtNuevaId.setText("" + tablaConductor.getValueAt(tablaConductor.getSelectedRow(), 3));
            txtNuevaDireccion.setText("" + tablaConductor.getValueAt(tablaConductor.getSelectedRow(), 4));
            txtNuevaEdad.setText("" + tablaConductor.getValueAt(tablaConductor.getSelectedRow(), 5));
            txtNuevoTelefono.setText("" + tablaConductor.getValueAt(tablaConductor.getSelectedRow(), 6));

            h = h.replace("Soltero/a", "1").replace("Casado/a", "2").replace("Divorciado/a", "3").replace("Viudo/a", "4").replace("Unión libre", "5").replace("Separado/a", "6");

            EstadoCivilId.setText("" + h);
            int p = Integer.parseInt(EstadoCivilId.getText());
            EstadoCivil.setSelectedIndex(p);

            lblIdConductor.setText("" + tablaConductor.getValueAt(tablaConductor.getSelectedRow(), 3));
            dlgModificar.setVisible(true);
        }

    }//GEN-LAST:event_btnModificarActionPerformed
//______________________________________________________________________________

    @SuppressWarnings("UnusedAssignment")
    private void btnAceptarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnAceptarActionPerformed

        String nuevoNombre = txtNuevoNombre.getText();
        String nuevoApellido = txtNuevoApellido.getText();
        String nuevaCedula = txtNuevaId.getText();
        String nuevaDireccion = txtNuevaDireccion.getText();
        String nuevaEdad = txtNuevaEdad.getText();
        String nuevoTelefono = txtNuevoTelefono.getText();
        int f2 = EstadoCivil.getSelectedIndex();

        boolean valida = true;
        while (valida) {

            if (ValidacionesPropietario.ValidacionesNomApe(nuevoNombre, txtNuevoNombre) || ValidacionesPropietario.ValidacionesNomApe(nuevoApellido, txtNuevoApellido) || ValidacionesPropietario.validaCedula(nuevaCedula, txtNuevaId)
                    || ValidacionesOpciones.validaDirecciones(nuevaDireccion, txtNuevaDireccion) || ValidacionesPropietario.validaEdad(nuevaEdad, txtNuevaEdad) || ValidacionesPropietario.validaTelefono(nuevoTelefono, txtNuevoTelefono) || f2 == 0) {
                valida = false;
                JOptionPane.showMessageDialog(jPanel3, "Por favor verifique los datos ingresados", "Error", JOptionPane.ERROR_MESSAGE);

            } else {
                modificarConductor();
                txtNuevoNombre.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
                txtNuevoApellido.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
                txtNuevaId.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
                txtNuevaDireccion.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
                txtNuevaEdad.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
                txtNuevoTelefono.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
                cbxEstadoCivil.setSelectedIndex(0);
                txtNuevoNombre.requestFocus();
            }
            valida = false;
        }

    }//GEN-LAST:event_btnAceptarActionPerformed
//______________________________________________________________________________

    private void cbxEstadoCivilItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbxEstadoCivilItemStateChanged

        int valor = cbxEstadoCivil.getSelectedIndex();

        if (valor == 1) {
            lblIdEstadoCivil.setText("1");
        } else if (valor == 2) {
            lblIdEstadoCivil.setText("2");
        } else if (valor == 3) {
            lblIdEstadoCivil.setText("3");
        } else if (valor == 4) {
            lblIdEstadoCivil.setText("4");
        } else if (valor == 5) {
            lblIdEstadoCivil.setText("5");
        } else if (valor == 6) {
            lblIdEstadoCivil.setText("6");
        }

    }//GEN-LAST:event_cbxEstadoCivilItemStateChanged
//______________________________________________________________________________

    private void EstadoCivilItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_EstadoCivilItemStateChanged

        int valor = EstadoCivil.getSelectedIndex();

        if (valor == 1) {
            EstadoId.setText("1");
        } else if (valor == 2) {
            EstadoId.setText("2");
        } else if (valor == 3) {
            EstadoId.setText("3");
        } else if (valor == 4) {
            EstadoId.setText("4");
        } else if (valor == 5) {
            EstadoId.setText("5");
        } else if (valor == 6) {
            EstadoId.setText("6");
        }

    }//GEN-LAST:event_EstadoCivilItemStateChanged
//______________________________________________________________________________

    private void txtBuscarKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_txtBuscarKeyReleased

        llenarConductores(txtBuscar.getText());

    }//GEN-LAST:event_txtBuscarKeyReleased
//______________________________________________________________________________

    private void cbxFiltroItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_cbxFiltroItemStateChanged

        int Valor = cbxFiltro.getSelectedIndex();

        if (Valor == 0) {
            txtBuscar.setText("");
            llenarConductores("");
        } else if (Valor == 1) {
            txtBuscar.setText("");
            llenarConductores("");
        }

    }//GEN-LAST:event_cbxFiltroItemStateChanged
//______________________________________________________________________________
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JComboBox EstadoCivil;
    private javax.swing.JLabel EstadoCivilId;
    private javax.swing.JLabel EstadoId;
    private javax.swing.JButton btnAceptar;
    private javax.swing.JButton btnEliminar;
    private javax.swing.JButton btnIngresar;
    private javax.swing.JButton btnModificar;
    private javax.swing.JButton btnVerTabla;
    private javax.swing.JComboBox cbxEstadoCivil;
    private javax.swing.JComboBox cbxFiltro;
    private javax.swing.JDialog dlgCargandoDatos;
    private javax.swing.JDialog dlgModificar;
    private javax.swing.JDialog dlgTablaConductor;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JLabel lblIdConductor;
    private javax.swing.JLabel lblIdEstadoCivil;
    private javax.swing.JProgressBar pbCargarDatos;
    private javax.swing.JTable tablaConductor;
    private javax.swing.JTextField txtApellido;
    private javax.swing.JTextField txtBuscar;
    private javax.swing.JTextField txtDireccion;
    private javax.swing.JTextField txtEdad;
    private javax.swing.JTextField txtIdConductor;
    private javax.swing.JTextField txtNombre;
    private javax.swing.JTextField txtNuevaDireccion;
    private javax.swing.JTextField txtNuevaEdad;
    private javax.swing.JTextField txtNuevaId;
    private javax.swing.JTextField txtNuevoApellido;
    private javax.swing.JTextField txtNuevoNombre;
    private javax.swing.JTextField txtNuevoTelefono;
    private javax.swing.JTextField txtTelefono;
    // End of variables declaration//GEN-END:variables
}
